package com.tencreat.service.account.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.tencreat.domain.account.AccountWaitBalance;
import com.tencreat.mapper.account.AccountWaitBalanceMapper;
import com.tencreat.service.account.IAccountWaitBalanceService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 未结算余额记录Service业务层处理
 *
 * @author tencreat
 * @date 2021-12-21
 */
@Service
public class AccountWaitBalanceServiceImpl extends ServiceImpl<AccountWaitBalanceMapper, AccountWaitBalance> implements IAccountWaitBalanceService {


    /**
     * 查询未结算余额记录
     *
     * @param id 未结算余额记录ID
     * @return 未结算余额记录
     */
    @Override
    public AccountWaitBalance selectAccountWaitBalanceById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询未结算余额记录列表
     *
     * @param accountWaitBalance 未结算余额记录
     * @return 未结算余额记录
     */
    @Override
    public List<AccountWaitBalance> selectAccountWaitBalanceList(AccountWaitBalance accountWaitBalance) {
        return baseMapper.selectList(Wrappers.query(accountWaitBalance));
    }

    /**
     * 新增未结算余额记录
     *
     * @param accountWaitBalance 未结算余额记录
     * @return 结果
     */
    @Override
    public int insertAccountWaitBalance(AccountWaitBalance accountWaitBalance) {
        accountWaitBalance.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(accountWaitBalance);
    }

    /**
     * 修改未结算余额记录
     *
     * @param accountWaitBalance 未结算余额记录
     * @return 结果
     */
    @Override
    public int updateAccountWaitBalance(AccountWaitBalance accountWaitBalance) {
        accountWaitBalance.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(accountWaitBalance);
    }

    /**
     * 批量删除未结算余额记录
     *
     * @param ids 需要删除的未结算余额记录ID
     * @return 结果
     */
    @Override
    public int deleteAccountWaitBalanceByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除未结算余额记录信息
     *
     * @param id 未结算余额记录ID
     * @return 结果
     */
    @Override
    public int deleteAccountWaitBalanceById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
